var express = require("express");
var router = express.Router();
var pomelo = require("pomelo");

//查询所有跑马灯
router.get("/getAllHeadlines", function(req, res) {
    let msg = req.query;
    pomelo.app.rpc.account.headlineRemote.findAllHeadlines(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//查询跑马灯
router.get("/getHeadlineById", function(req, res) {
    let msg = req.query;
    pomelo.app.rpc.account.headlineRemote.findHeadlineById(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//新增跑马灯
router.get("/addHeadline", function(req, res) {
    let msg = req.query;
    pomelo.app.rpc.account.headlineRemote.addHeadline(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//更新跑马灯
router.get("/updateHeadline", function(req, res) {
    let msg = req.query;
    pomelo.app.rpc.account.headlineRemote.updateHeadline(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//删除跑马灯
router.get("/deleteHeadline", function(req, res) {
    let msg = req.query;
    pomelo.app.rpc.account.headlineRemote.deleteHeadline(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

module.exports = router;